home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
misc
/
football
/
user
/
htmltemplates.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-11-29
|
16KB
|
535 lines
/* Mode=Run */
/* ***********************************************************************
HTMLTemplates.rexx v1.0 (03-7-99) for THE FOOTBALL REXX SUITE
-----------------------------------------------------------
by Heiko Schroeder (age@thepentagon.com)
-This script will generate an HTML file of the fixtures and results.
-To use HTMLTemplates.rexx you can run it by using the 'Run Script' button
on the Football main panel. Select HTMLTemplates.rexx from the file
requester and away you go. A file (????res.html) will be written to
Football/HTML/ but this location can be changed.
View the file with any browser that supports (coloured) tables.
-This are the Tags for your HTML-template
Write the Tags <!-- ... --> in your template at a separate line. This
Comment Tags will be replaced by this script with calculated data.
Check out Templates/German.html
GamesResultTags
<!-- HTMLTITLE --> Title of the League
<!-- DAYOFMATCH --> Number of Game
<!-- STARTDAYOFMATCH --> StartTag for ResultTable
<!-- MATCHDATE --> Date of the Game
<!-- HOMETEAM --> Team that plays at home
<!-- GOALSHOMETEAM --> Goals for team at home
<!-- GOALSGUESTTEAM --> Goals for team away
<!-- GUESTTEAM --> Team that plays away
<!-- ENDDAYOFMATCH --> EndTag for resultTable
TableTags
<!-- TABSTART --> StartTag for Table
<!-- TABPOSITION --> Position of team
<!-- TABTEAM --> Name of Team
<!-- TABGAMES --> played Games of a Team
<!-- TABWON --> wins
<!-- TABDRAWS --> draws
<!-- TABLOST --> lost
<!-- TABOWNGOALS --> own goals
<!-- TABGUESTGOALS --> guests goals
<!-- TABGOALDIFF --> difference of goals
<!-- TABPOINTS --> points at the saison
<!-- TABEND --> EndTag for Table
Navigation
<!-- BACK --> previous game results
<!-- BACKMATCH --> name of previous match link
<!-- NEXT --> next game results
<!-- NEXTMATCH --> name of next match link
You have two possibilities to create your HTML Site.
1.) Answer the following question with NO:
Do you want to create the HTML-Output via .data file?
2.) Create a file with the dates of a MatchDate. This file have to be
located in /FootBall/data/ with the extension: .webdata
The convention of the file or the requester has to be:
Number of MatchDate;First Day of MatchDate;Last Day of MatchDate.
e.g 2;27.August;29.August or for one day 6;07.September
The dates have to be the same dates at line *Date: in Data/#?.sf file.
(In Germany several matches from one MatchDate are played at
different days.)
Version Date History
--------------------------------------------------------------------------
0.9 030799 first internal release
without highscore tables
1.0 190799 first inofficial release
with integrated highscore tables
250899 Added more error messages and checking.
110999 Converted to use locale. Some error messages, before
reading the locale, will still be in English.
1.1 in future Tags for several statistics
************************************************************************** */
PARSE ARG league_file
htmlpath = "HTML/" /* path for your HTML files */
lname = league_file /* name for the HTML file taken from league file name */
version = 1
input_file = '.sf'
input2_file = '.df'
autosched = '*AUTOSCHD='
separator = '*'
HTMLTemplate= ''
output_file = "RAM:FBHTML.temp"
filesdone. = '???'
fdct = 0
league_file2= league_file
if pos("/",league_file) > 0 then
parse var league_file . "/" lname
lname = strip(lname)
league_file = "Data/"league_file
if open(datafile,"Data/Football.locale",'r') then do
line = readln(datafile)
locdir = strip(line)
close(datafile)
end
else do
say
say "ERROR : (HTMLTemplates)"
say
say "Cannot read 'Data/Football.locale' for the locale settings."
exit
end
locdir = locdir"User/HTMLTemplates.data"
if open(datafile,"ENV:FootballRXPath",'r') then do
line = readln(datafile)
rxdir = strip(line)
close(datafile)
end
else
rxdir = "SYS:Rexxc/"
if exists(locdir) > 0 then do
address command rxdir'rx 'locdir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (HTMLTemplates)"
say
say "Cannot find '"locdir"' to read locale settings."
exit
end
if exists(league_file || input_file) = 0 then do
say
say htt_error
say
say htt_t1"'"league_file || input_file"'."
exit
end
if exists(league_file || input2_file) = 0 then do
say
say htt_error
say
say htt_t1"'"league_file || input2_file"'."
exit
end
if exists("c:RequestChoice") = 0 then do
say
say htt_error
say
say htt_t1"'RequestChoice'"htt_t4
exit
end
if exists("c:RequestFile") = 0 then do
say
say htt_error
say
say htt_t1"'RequestFile'"htt_t4
exit
end
if exists("c:RequestString") = 0 then do
say
say htt_error
say
say htt_t1"'RequestString'"htt_t4
exit
end
autos = 0
/* .df file */
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(autosched,line) > 0 then do
autofile = delstr(line,1,10)
autos = 1
end
end
close(datafile)
end
else
Call ERRORFile
if autos = 0 then
Call ERRORFile2
/* Input data for generating special game datas */
address command 'c:RequestChoice Title="'htt_t7'" Body="'htt_t8'" Gadgets='htt_t9' >ram:FBHTML.temp'
if Open("Temp",output_file,"R") then do
Selection=readln("Temp")
Close("Temp")
end
else call ERRORFile4
/* Select HTML Template */
address command 'c:RequestFile DRAWER='Pragma(D)||'/HTMLTemplates PATTERN="#?.#?htm#?" TITLE="'htt_t10'" >ram:FBHTML.temp'
if Open("Temp",output_file,"R") then do
HTMLTemplate=strip(readln("Temp"),'B',d2c(34))
Close("Temp")
end
else call ERRORFile5
Time('R')
GameTime.0=0
If Selection=1 then do
if open(datatmpl,league_file'.webdata','r') then do
i=0
do while ~eof(datatmpl)
i=i+1; GameTime.i=readln(datatmpl)
If GameTime.i='' then i=i-1
end
close(datatmpl)
GameTime.0=i
End
else call ERRORFile6
End
else do
address command 'c:RequestString TITLE="HTMLTemplates.rexx" BODY="'htt_t11'" PATTERN=";;" >Ram:FBHTML.temp'
if Open("Temp",output_file,"R") then do
GameTime.1=readln("Temp")
GameTime.0=1
Close("Temp")
end
else call ERRORFile7
end
If GameTime.0=0 then do
say
say htt_error
say
say htt_t5
exit
end
Do z=1 to GameTime.0
semipos1=Pos(";",GameTime.z)
MatchNo=substr(GameTime.z,1,semipos1-1)
semipos2=Pos(";",GameTime.z,semipos1+1)
/* Nur ein Spieltag */
If semipos2=0 then do
MatchNoStart=substr(GameTime.z,semipos1+1)
MatchNoEnd =MatchNoStart
end
else do
MatchNoStart=substr(GameTime.z,semipos1+1,semipos2-semipos1-1)
MatchNoEnd =substr(GameTime.z,semipos2+1)
end
/* Read Dates from .sf */
LineNo=0
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
LineNo=LineNo+1
if pos('*DATE: ',upper(line))=1 then do
If pos(upper(MatchNoStart), upper(line))>0 then
DateStart=LineNo
If pos(upper(MatchNoEnd), upper(line))>0 then do
DateEnd=LineNo
Leave
End
End
End
close(datafile)
end
else call ERRORFile8
s=Datestart
s=Dateend
/* Read Game Datas from .sf file */
DasDatumNoch=0
DateCount=0
LineNo=0
/* Read file #?.sf for Gamedatas and store it in Arrays */
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
GameCount=0
line = readln(datafile)
LineNo=LineNo+1
if (pos('*DATE: ',upper(line))=1 & (DasDatumNoch=1)) then
leave
if pos('**',line) = 1 then
HTMLTitle=strip(substr(line,3,80))
if ((pos('*DATE: ',upper(line))=1) & (LineNo>=DateStart) & (LineNo<=DateEnd)) then do
DateCount=DateCount+1
Datum.DateCount=strip(substr(line,7,80))
If LineNo>=DateEnd then DasDatumNoch=1
/* Read line with separator * */
line = readln(datafile)
LineNo=LineNo+1
line = readln(datafile)
LineNo=LineNo+1
/* Read GameDatas */
Do While (pos(separator,line) = 0 & ~eof(datafile))
GameCount=GameCount+1
/* Heimmannschaft = t1 */
t1.DateCount.GameCount = strip(substr(line,1,30))
/* Heimmannschaft = gt1 */
gt1.DateCount.GameCount = strip(substr(line,31,3))
/* Gastmannschaft = t2 */
t2.DateCount.GameCount = strip(substr(line,40))
/* GoalGastmannschaft = gt2 */
gt2.DateCount.GameCount = strip(substr(line,36,3))
line = readln(datafile)
LineNo=LineNo+1
End
Menge.DateCount=GameCount
end
end
close(datafile)
end
else
Call ErrorFile3
/* read HTMLTemplate and replace the tags */
If open(template,HTMLTemplate,'r') then do
fdct = fdct + 1
filesdone.fdct = htmlpath||lname||"res"||MatchNo||".html"
/* Say "Create "htmlpath||lname||"res"||MatchNo||".html" */
open(stats,htmlpath||lname||"res"||MatchNo||".html","w")
do while ~eof(template)
TLine = readln(template)
Select
When pos('<!-- HTMLTITLE -->',upper(TLine)) then Call WriteData(HTMLTitle)
When pos('<!-- DAYOFMATCH -->',upper(TLine)) then Call WriteData(MatchNo||".")
When (pos('HREF="<!-- BACK -->">',upper(TLine)) & (MatchNo>1)) then
Call WriteData('HREF='||lname||'res'||MatchNo-1||'.html>')
When (pos('HREF="<!-- NEXT -->">',upper(TLine)) & (MatchNo<34)) then
Call WriteData('HREF='||lname||'res'||MatchNo+1||'.html>')
When (pos('<!-- BACKMATCH -->',upper(TLine)) & (MatchNo>1)) then
Call WriteData(MatchNo-1||'. Spieltag')
When (pos('<!-- NEXTMATCH -->',upper(TLine)) & (MatchNo<34)) then
Call WriteData(MatchNo+1||'. Spieltag')
When pos('<!-- STARTDAYOFMATCH -->',upper(TLine)) then do
StandOnLine=Seek(template,0,'C')
Do j = 1 to DateCount
DateIsWritten=0
Do k = 1 to Menge.j
Call Seek(template,StandOnLine,'B')
TLine = readln(template)
do while pos('<!-- ENDDAYOFMATCH -->',TLine)=0
Select
When (pos('<!-- MATCHDATE -->',upper(TLine)) & (DateIsWritten=0)) then do
Call WriteData(Datum.j)
DateIsWritten=1
End
When pos('<!-- HOMETEAM -->',upper(TLine)) then Call WriteData(t1.j.k)
When pos('<!-- GOALSHOMETEAM -->',upper(TLine)) then Call writeData(gt1.j.k)
When pos('<!-- GOALSGUESTTEAM -->',upper(TLine)) then Call writeData(gt2.j.k)
When pos('<!-- GUESTTEAM -->',upper(TLine)) then Call writeData(t2.j.k)
Otherwise call writeln(stats,TLine)
End
TLine = readln(template);
End
End /*do k*/
End /*j*/
End /*When*/
When pos('<!-- TABSTART -->',upper(TLine)) then do
StandOnLine=Seek(template,0,'C')
/* */
flag=1
interpret "call 'User/HTML_Table.rexx'(" 'league_file2' DateStart DateEnd flag ")"
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
/* */
Do k = 1 to varcount
Call Seek(template,StandOnLine,'B')
TLine = readln(template)
do while pos('<!-- TABEND -->',TLine)=0
Select
When pos('<!-- TABPOSITION -->',upper(TLine)) then Call WriteData(k)
When pos('<!-- TABTEAM -->',upper(TLine)) then Call writeData(substr(teams.k,1,35))
When pos('<!-- TABGAMES -->',upper(TLine)) then Call writeData(substr(teams.k,35,4))
When pos('<!-- TABWON -->',upper(TLine)) then Call writeData(substr(teams.k,39,4))
When pos('<!-- TABDRAWS -->',upper(TLine)) then Call writeData(substr(teams.k,43,4))
When pos('<!-- TABLOST -->',upper(TLine)) then Call writeData(substr(teams.k,47,4))
When pos('<!-- TABOWNGOALS -->',upper(TLine)) then Call writeData(substr(teams.k,51,6))
When pos('<!-- TABGUESTGOALS -->',upper(TLine)) then Call writeData(substr(teams.k,57,7))
When pos('<!-- TABPOINTS -->',upper(TLine)) then Call writeData(substr(teams.k,64,9))
When pos('<!-- TABGOALDIFF -->',upper(TLine)) then Call writeData(substr(teams.k,73))
Otherwise call writeln(stats,TLine)
End
TLine = readln(template);
End
End
End /* TabStart */
Otherwise call writeln(stats,TLine)
End
End
Close(Template)
close(stats)
End
else
Call ERRORHTMLCreator
End
/*
Say Time('E')
Say
*/
address command "c:Delete Ram:FBHTML.temp Quiet"
say
say center(htt_t6,78)
say "-------------------------------------------------------------------------------"
say
say
Say htt_t12
Say htt_t13" 'HTML/...'."
say
say htt_t14" : ("fdct")"
say
do i=1 to fdct
if filesdone.i ~= "" | filesdone.i ~= "???" then
say " '"filesdone.i"'"
end
say
exit
/* -------------------------------------------------------------------------------- */
WriteData:
Parse Arg Replacer
Replacer = strip(Replacer)
Call WriteLn(stats,Replacer)
Return
ErrorFile:
say
say htt_error
say
say htt_t2"'"league_file||input2_file"'"htt_t3
exit
ErrorFile2:
say
say htt_error
say
say htt_t15
say htt_t16
say htt_t17
say
exit
ErrorFile3:
say
say htt_error
say
say htt_t2"'"league_file||input_file"'"htt_t3
exit
ERRORHTMLCreator:
say
say htt_error
say
say htt_t18" '"HTMLTemplate"'"htt_t3
exit
ErrorFile4:
say
say htt_error
say
say htt_t2"'"output_file"' "htt_t19
exit
ErrorFile5:
say
say htt_error
say
say htt_t2"'"output_file"' "htt_t20
exit
ErrorFile6:
say
say htt_error
say
say htt_t2"'"league_file".webdata'"htt_t3
exit
ErrorFile7:
say
say htt_error
say
say htt_t2"'"output_file"' "htt_t21
exit
ErrorFile8:
say
say htt_error
say
say htt_t2"'"league_file||input_file"'"htt_3
exit
/* -------------------------------------------------------------------------------- */